<!-- src/components/Header.vue -->
<template>
    <div class="header">
        <div class="left">
            <i class="el-icon-s-fold collapse-btn" @click="$emit('toggle-collapse')"></i>
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/main/dashboard' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>{{ currentPageName }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="right">
            <el-badge :value="3" class="item">
                <i class="el-icon-bell" style="font-size: 20px; margin-right: 20px;"></i>
            </el-badge>
            <div class="user-avatar">A</div>
            <span>管理员</span>
            <el-dropdown>
                <i class="el-icon-arrow-down el-icon--right"></i>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item>退出登录</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>

<script setup lang="ts">
import {computed} from 'vue'
import {useRoute} from 'vue-router'

const route = useRoute()
const currentPageName = computed(() => {
    const map: any = {
        '/main/dashboard': '仪表盘',
        '/main/user': '用户管理',
        '/main/role': '角色管理',
        '/permission': '权限管理',
        '/product': '产品管理',
        '/main/posts/review':'审核管理',
        '/main/posts/manage':'帖子管理',
        '/category': '分类管理',
        '/order': '订单管理',
        '/setting': '系统设置'
    }
    return map[route.path] || '未知页面'
})
</script>

<style scoped>
.header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background-color: #fff;
    border-bottom: 1px solid #e6e6e6;
}

.left {
    display: flex;
    align-items: center;
}

.collapse-btn {
    font-size: 20px;
    cursor: pointer;
    color: #909399;
    margin-right: 20px;
}

.right {
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #409EFF;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}
</style>
